﻿using System.Collections.Generic;
using UnityEngine;
/*实现摄像机围绕旋转的功能*/
public class Camera_Exercise : MonoBehaviour
{
    public Transform centerTf;//设置旋转中心
    private void Update()
    {
        if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0))
        {
            //获取鼠标增量
            float mx = Input.GetAxis("Mouse X");
            float my = Input.GetAxis("Mouse Y");
            //transform.RotateAround(轴的位置,轴的方向,旋转角度);
            transform.RotateAround(centerTf.position ,Vector3.up,360*Time.deltaTime*mx);
            transform.RotateAround(centerTf.position,transform.right,360*Time.deltaTime*-my);
        }
    }
}
